library(ggplot2)
library(plotly)
library(dplyr)
library(DT)
library(readxl)
library(lubridate)
datos_policiales <-
readxl::read_excel("C:/Users/PC/Documents/2022 UCR I/PROCESAMIENTO DE DATOS/Datos Policiales/datos-policiales/estadisticaspoliciales2021.xls")
TABLA
datos_policiales %>%
dplyr::select(Delito, Fecha, Victima, Edad, Genero, Provincia, Canton) %>%
datatable(options = list (pageLength = 100), colnames = c("Delito", "Fecha", "Víctima", "Edad", "Género", "Provincia", "Cantón"))
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html
Grafico
grafico <-
datos_policiales %>%
count(Delito) %>%
ggplot(aes(x = reorder(Delito, n), y = n)) +
geom_bar(stat = "identity") +
coord_flip() +
ggtitle("Registro de Delitos") +
xlab("Delito") +
ylab("Cantidad") +
theme_minimal()
ggplotly(grafico) %>% config(locale = 'es')
GRAFICO DELITOS POR MES
datos_policiales %>%
ggplot(aes(x = Delito, y = Fecha)) +
geom_bar(stat = "identity") +
coord_flip()

GRAFICO CANTONES
datos_policiales %>%
ggplot(aes(x = Delito, y = Canton)) +
geom_bar(stat = "identity") +
coord_flip()
